<?php
set_time_limit(0);
$root=preg_replace('/cron$/', '', dirname(__FILE__));

require_once($root."inc.config.php");

require_once($root."initialize.php");

if(($db_msg=cron_initialize()) !== true){

	print_r("Connection error");

}else{ 

	$db=$vars["db"];

	
		$t = @mysql_num_rows($r=mysql_query("select id from gg_users where code=0"));
		
		if($t<=0)
		{
			print_r("no record");
			exit;
		}

		while($user = mysql_fetch_assoc($r))
		{
			$code = rand() % 999999;
			$exist = false;
			while($code<100000 || $exist==true){
				$code = rand() % 999999;
				$ts = @mysql_num_rows($rs=mysql_query("select id from gg_users where code=".$code));
				if($ts<=0)
					$exist = false;
				else 
					$exist = true;
			}

			mysql_query("update gg_users set code=".$code." where id=".$user['id']);
		}

	print_r("finish");
}
?>